class WndMain : public Wnd
{
friend class WndMainCtlr;
public:
	WndMain(LPCTSTR WndText = TEXT("NewMainWindow"), DWORD dwStyle = WS_OVERLAPPEDWINDOW, 
		int x = CW_USEDEFAULT,  int y = 0,  int nWidth = CW_USEDEFAULT,  int nHeight = 0,
		HWND hWndParent = NULL,  HMENU hMenu = NULL,  HINSTANCE hInstance = Application::hInst, LPVOID lpParam = NULL);
protected:
	virtual ATOM MyRegisterClass(HINSTANCE hInstance);

	virtual BOOL isWndClassRegistered() {return isClassRegistered;}
	virtual void setWndClassRegistered() {isClassRegistered = TRUE;}
	virtual LPCWSTR getWndClassName() {return wndClassName;}
	static BOOL isClassRegistered;
	static TCHAR wndClassName[MAX_LOADSTRING];
};

/* Custom Messages */
#define MSG_MAIN_SHOWSELECTCELL			WM_USER+100
#define MSG_MAIN_SHOWSTATUEINFO			WM_USER+101
#define MSG_MAIN_GOTO					WM_USER+102

class WndMainCtlr : public WndController
{
public:
	WndMainCtlr();
protected:
	static LRESULT CALLBACK OnCreate(HWND hWnd, WPARAM wParam, LPARAM lParam);
	static LRESULT CALLBACK OnClose(HWND hWnd, WPARAM wParam, LPARAM lParam);
	static LRESULT CALLBACK OnSize(HWND hWnd, WPARAM wParam, LPARAM lParam);
	static LRESULT CALLBACK OnFocus(HWND hWnd, WPARAM wParam, LPARAM lParam);
	static LRESULT CALLBACK OnEraseBG(HWND hWnd, WPARAM wParam, LPARAM lParam);	
	static LRESULT CALLBACK OnTimer(HWND hWnd, WPARAM wParam, LPARAM lParam);
	
	static LRESULT CALLBACK OnShowAbout(HWND hWnd, WPARAM wParam, LPARAM lParam);
	static LRESULT CALLBACK OnExit(HWND hWnd, WPARAM wParam, LPARAM lParam);
	static LRESULT CALLBACK OnFileNew(HWND hWnd, WPARAM wParam, LPARAM lParam);
	static LRESULT CALLBACK OnFileOpen(HWND hWnd, WPARAM wParam, LPARAM lParam);
	static LRESULT CALLBACK OnFileSave(HWND hWnd, WPARAM wParam, LPARAM lParam);
	static LRESULT CALLBACK OnFileSaveAs(HWND hWnd, WPARAM wParam, LPARAM lParam);
	
	static LRESULT CALLBACK OnCopy(HWND hWnd, WPARAM wParam, LPARAM lParam);
	static LRESULT CALLBACK OnCut(HWND hWnd, WPARAM wParam, LPARAM lParam);
	static LRESULT CALLBACK OnPaste(HWND hWnd, WPARAM wParam, LPARAM lParam);
	static LRESULT CALLBACK OnUndo(HWND hWnd, WPARAM wParam, LPARAM lParam);
	static LRESULT CALLBACK OnRedo(HWND hWnd, WPARAM wParam, LPARAM lParam);
	static LRESULT CALLBACK OnDelete(HWND hWnd, WPARAM wParam, LPARAM lParam);
	static LRESULT CALLBACK OnGoto(HWND hWnd, WPARAM wParam, LPARAM lParam);
	static LRESULT CALLBACK OnSelectAll(HWND hWnd, WPARAM wParam, LPARAM lParam);

	static LRESULT CALLBACK InsertRow(HWND hWnd, WPARAM wParam, LPARAM lParam);
	static LRESULT CALLBACK InsertColumn(HWND hWnd, WPARAM wParam, LPARAM lParam);
	static LRESULT CALLBACK RemoveRow(HWND hWnd, WPARAM wParam, LPARAM lParam);
	static LRESULT CALLBACK RemoveColumn(HWND hWnd, WPARAM wParam, LPARAM lParam);

	static LRESULT CALLBACK OnShowGridLine(HWND hWnd, WPARAM wParam, LPARAM lParam);
	static LRESULT CALLBACK OnShowHeader(HWND hWnd, WPARAM wParam, LPARAM lParam);
	static LRESULT CALLBACK OnZoomDef(HWND hWnd, WPARAM wParam, LPARAM lParam);
	static LRESULT CALLBACK OnZoom50(HWND hWnd, WPARAM wParam, LPARAM lParam);
	static LRESULT CALLBACK OnZoom150(HWND hWnd, WPARAM wParam, LPARAM lParam);
	static LRESULT CALLBACK OnShowSelect(HWND hWnd, WPARAM wParam, LPARAM lParam);

	static LRESULT CALLBACK OnSetTextColor(HWND hWnd, WPARAM wParam, LPARAM lParam);
	static LRESULT CALLBACK OnSetBackColor(HWND hWnd, WPARAM wParam, LPARAM lParam);
	static LRESULT CALLBACK OnStyleClear(HWND hWnd, WPARAM wParam, LPARAM lParam);
	static LRESULT CALLBACK OnAlignLeft(HWND hWnd, WPARAM wParam, LPARAM lParam);
	static LRESULT CALLBACK OnAlignRight(HWND hWnd, WPARAM wParam, LPARAM lParam);
	static LRESULT CALLBACK OnAlignCenter(HWND hWnd, WPARAM wParam, LPARAM lParam);
	static LRESULT CALLBACK OnVAlignTop(HWND hWnd, WPARAM wParam, LPARAM lParam);
	static LRESULT CALLBACK OnVAlignCenter(HWND hWnd, WPARAM wParam, LPARAM lParam);
	static LRESULT CALLBACK OnVAlignBottom(HWND hWnd, WPARAM wParam, LPARAM lParam);
	static LRESULT CALLBACK OnGotoChosen(HWND hWnd, WPARAM wParam, LPARAM lParam);

	static LRESULT CALLBACK OnFontSelect(HWND hWnd, WPARAM wParam, LPARAM lParam);
	static LRESULT CALLBACK OnFontBold(HWND hWnd, WPARAM wParam, LPARAM lParam);
	static LRESULT CALLBACK OnFontItalic(HWND hWnd, WPARAM wParam, LPARAM lParam);
	static LRESULT CALLBACK OnFontUnderline(HWND hWnd, WPARAM wParam, LPARAM lParam);
	static LRESULT CALLBACK OnFontStrick(HWND hWnd, WPARAM wParam, LPARAM lParam);

private:
	static void UpdateWindowTitle(HWND hWnd);
	static void CheckUndoRedo(HMENU hMenu);

	static int cxChar, cxCaps, cyChar, cxClient, cyClient;
	static HWND hToolBar, hWndGrid;
	static StatusBar statusBar;
};